package com.digital.smartgrow.service.notice.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.digital.smartgrow.common.util.WebTool;
import com.digital.smartgrow.dto.notice.WaitNoticePageDTO;
import com.digital.smartgrow.entity.notice.WaitNotice;
import com.digital.smartgrow.dao.notice.WaitNoticeMapper;
import com.digital.smartgrow.service.notice.WaitNoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 通知 服务实现类
 * </p>
 *
 * @author sunyuechao
 * @since 2022-07-14
 */
@Service
public class WaitNoticeServiceImpl extends ServiceImpl<WaitNoticeMapper, WaitNotice> implements WaitNoticeService {

    @Override
    public Object getListByPage(WaitNoticePageDTO pageDTO) {
        Page<WaitNotice> page = new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize());

        QueryWrapper<WaitNotice> wrapper = new QueryWrapper<>();
        wrapper.eq("userId", WebTool.getCurrentUser().getId());
        wrapper.eq("status", 0);
        wrapper.eq("noticeType", 1);
        return this.page(page, wrapper);
    }

    @Override
    public WaitNotice getInfo(Integer id) {
        return this.getById(id);
    }
}
